package com.kara.woodAgent.agent.wood;

import com.kara.woodAgent.agent.graph.impl.SubGraphNodeImpl;
import com.kara.woodAgent.agent.model.ModelProvider;
import com.kara.woodAgent.agent.tool.provider.ToolProvider;
import com.kara.woodAgent.agent.wood.context.WoodContext;
import com.kara.woodAgent.agent.wood.context.WoodReactContext;
import com.kara.woodAgent.agent.wood.model.SpecialAgentWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class SpecialAgentConfig {

    @Autowired
    private ToolProvider toolProvider;


    @Autowired
    private ModelProvider modelProvider;


    @Bean("file")
    public SpecialAgentWrapper fileSpecialAgent() {
        ToolProvider.ToolServiceHolder serviceHolder = toolProvider.getToolService(List.of("file", "system"));

        SubGraphNodeImpl<WoodContext, WoodReactContext> subNode = SpecialAgentTemplate.createSubGraphNode(modelProvider, serviceHolder);

        SpecialAgentWrapper specialAgentWrapper = new SpecialAgentWrapper();
        specialAgentWrapper.setGraph(subNode);
        specialAgentWrapper.setDescription("本地文件交互智能体,可以实现和本地操作系统io文件交互，包括创建，读取，写入等操作");
        specialAgentWrapper.setAgentName("file");
        return specialAgentWrapper;
    }


    @Bean("writer")
    public SpecialAgentWrapper writerSpecialAgent() {
        ToolProvider.ToolServiceHolder serviceHolder = toolProvider.getToolService(List.of("file", "search", "system"));

        SubGraphNodeImpl<WoodContext, WoodReactContext> subNode = SpecialAgentTemplate.createSubGraphNode("##### 要求：编写完成的文章，报告等，清保存到D盘 writer 文件夹下，用于之后下载访问使用",modelProvider, serviceHolder);

        SpecialAgentWrapper specialAgentWrapper = new SpecialAgentWrapper();
        specialAgentWrapper.setGraph(subNode);
        specialAgentWrapper.setDescription("作家智能体，可以联网搜索获得资料，并可以完成文章，报告等写作工作");
        specialAgentWrapper.setAgentName("writer");
        return specialAgentWrapper;
    }


    @Bean("search")
    public SpecialAgentWrapper searchSpecialAgent() {
        ToolProvider.ToolServiceHolder serviceHolder = toolProvider.getToolService(List.of("search", "system"));

        SubGraphNodeImpl<WoodContext, WoodReactContext> subNode = SpecialAgentTemplate.createSubGraphNode(modelProvider, serviceHolder);

        SpecialAgentWrapper specialAgentWrapper = new SpecialAgentWrapper();
        specialAgentWrapper.setGraph(subNode);
        specialAgentWrapper.setDescription("网络搜索智能体，可以实现联网搜索操作，访问网页等");
        specialAgentWrapper.setAgentName("search");
        return specialAgentWrapper;
    }


    @Bean("time")
    public SpecialAgentWrapper timeSpecialAgent() {
        ToolProvider.ToolServiceHolder serviceHolder = toolProvider.getToolService(List.of("time", "system"));

        SubGraphNodeImpl<WoodContext, WoodReactContext> subNode = SpecialAgentTemplate.createSubGraphNode(modelProvider, serviceHolder);

        SpecialAgentWrapper specialAgentWrapper = new SpecialAgentWrapper();
        specialAgentWrapper.setGraph(subNode);
        specialAgentWrapper.setDescription("时间智能体，可以获得当前时间，可以用于和时间获取相关的问题");
        specialAgentWrapper.setAgentName("time");
        return specialAgentWrapper;
    }
}
